<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://www.springframework.org/security/tags"
	prefix="sec"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<!--[if IE 9 ]><html class="ie9"><![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Telomere</title>
<link rel="shortcut icon" href="<%=path%>/img/logo.png">

<!-- Vendor CSS -->
<link
	href="<%=path%>/vendors/bower_components/animate.css/animate.min.css"
	rel="stylesheet">
<link
	href="<%=path%>/vendors/bower_components/sweetalert2/dist/sweetalert2.min.css"
	rel="stylesheet">
<link
	href="<%=path%>/vendors/bower_components/material-design-iconic-font/dist/css/material-design-iconic-font.min.css"
	rel="stylesheet">
<link
	href="<%=path%>/vendors/bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css"
	rel="stylesheet">
<link
	href="<%=path%>/vendors/bower_components/bootstrap-select/dist/css/bootstrap-select.css"
	rel="stylesheet">
<link href="<%=path%>/vendors/bower_components/chosen/chosen.css"
	rel="stylesheet">

<!-- CSS -->
<link href="<%=path%>/css/app_1.min.css" rel="stylesheet">
<link href="<%=path%>/css/app_2.min.css" rel="stylesheet">
<link href="<%=path%>/css/custom.css" rel="stylesheet">
<link href="<%=path%>/css/box.css" rel="stylesheet">
</head>
<body>
	<%@ include file="../header.jsp"%>
	<section id="main">
		<%@ include file="../sidebar.jsp"%>
		<section id="content">
			<div class="container">
				<div class="block-header">
					<h2>分析结果</h2>
				</div>
				<div class="row">
					<div class="col-md-6">
						<div class="card">
							<div class="card-header">
								<h2 class="card-title">QC of Plate A</h2>
							</div>
							<div class="card-block">
								<div class="chart-container" id="container_A"></div>
								<script>
									var A_d1 = [];
									var A_d2 = [];
									var A_a0 = <s:property value="lr_tel.a0"/>;
									var A_a1 = <s:property value="lr_tel.a1"/>;
									var A_R2 = <s:property value="lr_tel.r2"/>;
									var x ,
										y;
								</script>
								<s:iterator value="lr_tel.dlist">
									<script>
										x = <s:property value="x"/>;
										y = <s:property value="y"/>;
										A_d1.push([ x, y ]);
										A_d2.push([ x, x * A_a1 + A_a0 ]);
									</script>
								</s:iterator>
							</div>
						</div>
					</div>
					<div class="col-md-6">
						<div class="card">
							<div class="card-header">
								<h2 class="card-title">QC of Plate B</h2>
							</div>
							<div class="card-block">
								<div class="chart-container" id="container_B"></div>
								<script>
									var B_d1 = [];
									var B_d2 = [];
									var B_a0 = <s:property value="lr_36b.a0"/>;
									var B_a1 = <s:property value="lr_36b.a1"/>;
									var B_R2 = <s:property value="lr_36b.r2"/>;
								</script>
								<s:iterator value="lr_36b.dlist">
									<script>
										x = <s:property value="x"/>;
										y = <s:property value="y"/>;
										B_d1.push([ x, y ]);
										B_d2.push([ x, x * B_a1 + B_a0 ]);
									</script>
								</s:iterator>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="card">
						<div class="card-body card-padding">

							<div class="div-table-margin">
								<div class="row">
									<div class="col-sm-3">
										<div class="form-group fg-line" style="margin-top:4px;">
											<div class="select">
												<select id="select-status" class="selectpicker">
													<option value="0">保留小数（请选择）</option>
													<option value="2">2位小数</option>
													<option value="4">4位小数</option>
													<option value="6">6位小数</option>
												</select>
											</div>
										</div>
									</div>
								</div>
								<div class="div-divider"></div>
								<br />
								<div class="table-responsive">
									<table class="table table-bordered table-striped">
										<thead>
											<tr>
												<th>编号</th>
												<th>内部编号</th>
												<th>性别</th>
												<th>年龄</th>
												<th>CT(Plate A)</th>
												<th>CT平均值(Plate A)</th>
												<th>浓度(Plate A)</th>
												<th>CT(Plate B)</th>
												<th>CT平均值(Plate B)</th>
												<th>浓度(Plate B)</th>
												<th>端粒长度</th>
												<!-- <th>长度超过同年龄段</th> -->
											</tr>
										</thead>
										<tbody>
											<form id="form-report" method="post" action="<%=path%>/telo!report.action">
											<s:hidden name="qcFailedSample" />
											<s:iterator value="tlist" status="ts">
												
												<tr>
													<s:if test='ct_quality_36b == 1 && ct_quality_tel == 1'>
														<input type="hidden" name="trlist[<s:property value='#ts.index'/>].internal_id" value="<s:property value='tr.internal_id' />"/>
													</s:if>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].name" value="<s:property value='tr.name' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].gender" value="<s:property value='tr.gender' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].dob" value="<s:property value='tr.dob' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].age" value="<s:property value='tr.age' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].tel" value="<s:property value='tr.tel' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].concentration" value="<s:property value='tr.concentration' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].volume" value="<s:property value='tr.volume' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].box" value="<s:property value='tr.box' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].position" value="<s:property value='tr.position' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].technician" value="<s:property value='tr.technician' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].sample_type" value="<s:property value='tr.sample_type' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].analysis_date" value="<s:property value='tr.analysis_date' />"/>
													<input type="hidden" name="trlist[<s:property value='#ts.index'/>].atl" value="<s:property value='con_log_delta' />"/>
													<td><s:property value="sname" /></td>
													<td><s:property value="tr.internal_id" /></td>
													<td><s:property value="tr.gender" /></td>
													<td><s:property value="tr.age" /></td>
													<s:if test="ct_quality_tel == 1">
														<td style="color:#32c787;"><s:iterator value="ct_tel" status="sta">
															<s:if test="#sta.index != 0">
																&nbsp;,&nbsp;
															</s:if>
															<input type="hidden" value="<s:property />"/>
															<span class="span-value"><s:property /></span>
														</s:iterator></td>
													</s:if>
													<s:else>
														<td style="color:#ff6b68;"><s:iterator value="ct_tel" status="sta">
															<s:if test="#sta.index != 0">
																&nbsp;,&nbsp;
															</s:if>
															<input type="hidden" value="<s:property />"/>
															<span class="span-value"><s:property /></span>
														</s:iterator></td>
													</s:else>
													<td>
														<input type="hidden" value="<s:property value='ct_mean_tel'/>"/>
														<span class="span-value"><s:property value="ct_mean_tel" /></span>
													</td>
													<td>
														<input type="hidden" value="<s:property value='con_tel'/>"/>
														<span class="span-value"><s:property value="con_tel" /></span>
													</td>
													<s:if test="ct_quality_36b == 1">
														<td style="color:#32c787;"><s:iterator value="ct_36b" status="sta">
															<s:if test="#sta.index != 0">
																&nbsp;,&nbsp;
															</s:if>
															<input type="hidden" value="<s:property />"/>
															<span class="span-value"><s:property /></span>
														</s:iterator></td>
													</s:if>
													<s:else>
														<td style="color:#ff6b68;"><s:iterator value="ct_36b" status="sta">
															<s:if test="#sta.index != 0">
																&nbsp;,&nbsp;
															</s:if>
															<input type="hidden" value="<s:property />"/>
															<span class="span-value"><s:property /></span>
														</s:iterator></td>
													</s:else>
													<td>
														<input type="hidden" value="<s:property value='ct_mean_36b'/>"/>
														<span class="span-value"><s:property value="ct_mean_36b" /></span>
													</td>
													<td>
														<input type="hidden" value="<s:property value='con_36b'/>"/>
														<span class="span-value"><s:property value="con_36b" /></span>
													</td>
													<td>
														<input type="hidden" value="<s:property value='con_log_delta'/>"/>
														<span class="span-value"><s:property value="con_log_delta" /></span>
													</td>
													<!-- 
													<td>
														<s:if test="percentage < 30">
															<span style="color:#ff6b68;">
																<s:property value="percentage"/>%
															</span>
														</s:if>
														<s:elseif test="percentage >= 30 && percentage <= 70">
															<span style="color:#FF9800;">
																<s:property value="percentage"/>%
															</span>
														</s:elseif>
														<s:else>
															<span style="color:#32c787;">
																<s:property value="percentage"/>%
															</span>
														</s:else>
													</td>
													 -->
												</tr>
											</s:iterator>
											</form>
										</tbody>
									</table>
								</div>
								<br/>
								<div class="div-divider"></div>
								<br/>
								<div class="row">
									<s:iterator value="warninglist">
										<p class="p-warning">
											<s:property />
										</p>
									</s:iterator>
								</div>
								<div class="form-group" style="text-align:center;">
									<button id="button-report" type="button" class="btn bgm-green" onclick="report()">生成报告</button>
									<span id="span-report" style="color:#673AB7;font-size:20px;display:none;">…… 正在处理中，请稍等 ……</span>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</section>
	</section>

	<%@ include file="../footer.jsp"%>


	<!-- Javascript Libraries -->

	<script
		src="<%=path%>/vendors/bower_components/jquery/dist/jquery.min.js"></script>
	<script
		src="<%=path%>/vendors/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

	<script
		src="<%=path%>/vendors/bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"></script>
	<script
		src="<%=path%>/vendors/bower_components/Waves/dist/waves.min.js"></script>
	<script src="<%=path%>/vendors/bootstrap-growl/bootstrap-growl.min.js"></script>
	<script
		src="<%=path%>/vendors/bower_components/sweetalert2/dist/sweetalert2.min.js"></script>
	<script src="<%=path%>/js/es6-promise.auto.js"></script>
	<script
		src="<%=path%>/vendors/bower_components/moment/min/moment.min.js"></script>
	<script
		src="<%=path%>/vendors/bower_components/autosize/dist/autosize.min.js"></script>
	<script
		src="<%=path%>/vendors/bower_components/bootstrap-select/dist/js/bootstrap-select.js"></script>
	<script
		src="<%=path%>/vendors/bower_components/chosen/chosen.jquery.js"></script>
	<script src="<%=path%>/vendors/fileinput/fileinput.js"></script>
	<script src="<%=path%>/js/flotr2.min.js"></script>
	<!-- Placeholder for IE9 -->
	<!--[if IE 9 ]>
            <script src="<%=path%>/vendors/bower_components/jquery-placeholder/jquery.placeholder.min.js"></script>
        <![endif]-->
	<script src="<%=path%>/js/app.js"></script>
	<script>
		jQuery(document).ready(function() {
			var container_A = document.getElementById('container_A');
	
			// Draw the graph
			graph = Flotr.draw(
				container_A, [
					{
						data : A_d1,
						points : {
							show : true
						}
					},
					{
						data : A_d2,
						label : "&nbsp;R<sup>2</sup> = " + A_R2.toFixed(6)
					}
				],
				{
					xaxis : {
						title : "CT Mean"
					},
					yaxis : {
						title : "Log C"
					},
					grid : {
						labelMargin : 20
					},
					mouse : {
						track : true
					},
					legend : {
						position : 'ne',
						backgroundColor : '#D2E8FF'
					}
				}
			);
	
			var container_B = document.getElementById('container_B');
	
			// Draw the graph
			graph = Flotr.draw(
				container_B, [
					{
						data : B_d1,
						points : {
							show : true
						}
					},
					{
						data : B_d2,
						label : "&nbsp;R<sup>2</sup> = " + B_R2.toFixed(6)
					}
				],
				{
					xaxis : {
						title : "CT Mean"
					},
					yaxis : {
						title : "Log C",
						titlesAngle : 270
					},
					grid : {
						labelMargin : 20
					},
					mouse : {
						track : true
					},
					legend : {
						position : 'ne',
						backgroundColor : '#D2E8FF'
					}
				}
			);
			
			$("#select-status").change(function(){
				var n = $("#select-status").val();
				if(n != 0){
					$(".span-value").each(function(){
						var v = Number($(this).prev().val());
						$(this).html(v.toFixed(n));
  					});
				}
				else{
					$(".span-value").each(function(){
						var v = Number($(this).prev().val());
						$(this).html(v);
  					});
				}
			});
		});
		
		function report(){
			$('#button-report').hide();
			$('#span-report').show();
			$('#form-report').submit();
		}
	</script>
</body>
</html>